<template>
  <div class="song-list-item-div" >
    <div class="order" v-if="order">{{ order }}</div>
    <li
      class="song-list-item"
      :class="{
        active: currentSong && currentSong.id === item.id,
        playing: currentSong && currentSong.id === item.id && playing,
      }"
    >
      <div class="left">
        <!-- 这里是歌名 -->
        <h5>
          {{ item.name }}
          <!-- 这里是别名 -->
          <span
            v-for="(ali, index) in item.song ? item.song.alias : item.alia"
            :key="index"
            >({{ ali }})</span
          >
        </h5>

        <p>
          <!-- 这里是歌手名字 -->
          <b>
            <span
              v-for="(artist, index) in item.song ? item.song.artists : item.ar "
              :key="index"
              >{{ artist.name}}</span
            ></b
          >
          -
          <!-- 这里是歌手名字旁边的专辑名 -->
          <i>{{ item.song ? item.song.album.name : item.al.name }}</i>
        </p>
      </div>
      <!-- 这里是播放图标 -->
      <div class="icon">
        <span class="icon-span iconfont icon-bofang"></span>
        <div class="playicon">
          <span></span>
          <span></span>
          <span></span>
          <span></span>
        </div>
      </div>
    </li>
  </div>
</template>

<script>
export default {
  props: {
    item: Object,
    order: Number,
    currentSong: [Object, null],
    playing: Boolean,
  },
};
</script>

<style lang="less">
.song-list-item-div {
  display: flex;
  margin: 5px 0;
  .order {
    width: 40px;
    text-align: center;
    line-height: 47px;
  }
  .song-list-item {
    display: flex;
    flex: 1;
    align-items: center;
    margin: 0px 10px;
    padding: 6px 0px;
    border-bottom: 1px solid #f2f2f3;

    .left {
      flex: 1;
      h5 {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        overflow: hidden;
        color: #333;
        font-size: 17px;
        font-weight: none;
        padding-right: 10px;
        span {
          color: gray;
        }
      }
      p {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        overflow: hidden;
        font-size: 12px;
        color: #888;
        padding-right: 10px;
        b {
          font-weight: normal;
          span {
            &::after {
              content: "/";
            }
            &:last-child {
              &::after {
                content: "";
              }
            }
            &:first-child {
              &::before {
                content: "";
                display: inline-block;
                width: 12px;
                height: 8px;
                margin-right: 4px;
                background-image: url("@/assets/index_icon_2x.png");
                background-repeat: no-repeat;
                background-size: 166px 97px;
              }
            }
          }
        }
      }
    }
    .icon {
      width: 30px;
      height: 30px;
      .icon-span {
        font-size: 22px;
        color: #aaa;
        line-height: 30px;
      }
      .playicon {
        display: none;
      }
    }
    &.active {
      .icon {
        .icon-span {
          display: none;
        }
        .playicon {
          display: flex;
          justify-content: space-between;
          width: 20px;
          height: 20px;
          span {
            width: 12%;
            height: 100%;
            background-color: red;
            display: inline-block;
            animation: loading 1s linear infinite alternate;
            transform-origin: bottom;
            animation-play-state: paused;
            &:nth-child(1) {
              animation-delay: -0.6s;
            }
            &:nth-child(2) {
              animation-delay: -0.2s;
            }
            &:nth-child(3) {
              animation-delay: -0.4s;
            }
            &:nth-child(4) {
              animation-delay: 0s;
            }
          }
        }
      }
      &.playing {
        .icon {
          .playicon {
            span {
              animation-play-state: running;
            }
          }
        }
      }
    }
  }
}
@keyframes loading {
  from {
    transform: rotateX(90deg);
  }
  to {
    transform: rotateX(0deg);
  }
}
</style>